# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=wapiti
_pkgname=wapiti3
pkgver=3.2.10.r0.gd7e7d4e
pkgrel=1
groups=('blackarch' 'blackarch-webapp' 'blackarch-scanner' 'blackarch-fuzzer')
pkgdesc='A vulnerability scanner for web applications.'
url='https://github.com/wapiti-scanner/wapiti'
license=('GPL-2.0-only')
depends=('python' 'python-httpx' 'python-httpx-socks' 'python-beautifulsoup4'
         'python-tld' 'python-yaswfp' 'python-mako' 'python-pysocks'
         'python-markupsafe' 'python-six' 'python-importlib-metadata'
         'python-browser-cookie3' 'python-cryptography' 'python-sqlalchemy'
         'python-aiosqlite' 'python-loguru' 'python-dnspython' 'python-socksio'
         'python-httpcore' 'sslyze' 'python-humanize' 'python-keyring'
         'python-aiocache' 'python-brotli' 'python-brotlicffi' 'python-h11'
         'python-async-timeout' 'python-pyasn1' 'python-arsenic' 'mitmproxy'
         'python-prance' 'python-wapiti-arsenic' 'python-httpx-ntlm'
         'python-pyspnego' 'python-wapiti-swagger')
makedepends=('git' 'python-setuptools' 'python-wheel' 'python-pip')
arch=('any')
source=("git+https://github.com/wapiti-scanner/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

prepare() {
  cd $pkgname

  #sed -ri 's/==/>=/g' setup.py
}

build() {
  cd $pkgname

  python -m build --wheel --outdir="$startdir/dist"
}

package() {
  cd $pkgname

  pip install \
    --verbose \
    --disable-pip-version-check \
    --no-warn-script-location \
    --ignore-installed \
    --no-compile \
    --no-deps \
    --root="$pkgdir" \
    --prefix=/usr \
    --no-index \
    --find-links="file://$startdir/dist" \
    $_pkgname

	install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.rst INSTALL.md \
    VERSION doc/AUTHORS doc/ChangeLog* doc/*.md doc/*.txt doc/*.html doc/*.ico
}

